package 类与对象.枚举;

import java.util.ArrayList;
import java.util.List;

/*
    1.当我们是enum关键字开发一个枚举类时，默认会继承Enum类，而且是一个final类
    2.传统的public static final Season SPRING = new Season("春天","生机勃勃")，必须知道它调用的那个类
    3.如果使用无参构造器创建枚举时，则实参列表和小括号都可以省略
    4.当有多个枚举对象时，使用","间隔，最后一个分号结尾
    5.枚举对象必须放在枚举类的首行
 */
public class 关键字 {
    public static void main(String[] args) {
        Season spring = Season.AUTUMN;
        //输出对象的运行类型
        System.out.println(spring.getClass());
        //输出枚举对象的名称
        System.out.println(spring.name());
        //枚举对象位置
        System.out.println(spring.ordinal());
        //含有所有枚举对象的数组
        System.out.println(spring.values());
        Season[] values = spring.values();
        for (Season value : values) {
            System.out.println(value);
        }
        //将字符串转化成枚举对象，如果枚举不在对象数组就报错
        Season autumn = spring.valueOf("AUTUMN");
        System.out.println(autumn == spring);
        //判断两个枚举对象的位置
        System.out.println(Season.SPRING.compareTo(Season.AUTUMN));

    }
}
/*
      final class 类与对象.枚举.Season extends java.lang.Enum<类与对象.枚举.Season> {
      public static final 类与对象.枚举.Season SPRING;
      public static final 类与对象.枚举.Season WINTER;
      public static final 类与对象.枚举.Season AUTUMN;
      public static final 类与对象.枚举.Season SUMMER;
      public static 类与对象.枚举.Season[] values();
      public static 类与对象.枚举.Season valueOf(java.lang.String);
      public java.lang.String getName();
      public java.lang.String getDesc();
      public java.lang.String toString();
      static {};
}

 */
enum Season{


//    public static final Season SPRING = new Season("春天","生机勃勃");
//    public static final Season WINTER = new Season("冬天","寒风刺骨");
//    public static final Season AUTUMN = new Season("秋天","秋高气爽");
//    public static final Season SUMMER = new Season("春天","夏日炎炎");

    SPRING("春天","生机勃勃"),
    WINTER("冬天","寒风刺骨"),
    AUTUMN("秋天","秋高气爽"),
    SUMMER("春天","夏日炎炎");
    private String name;
    private String desc;


    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }

    private Season(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }
}

enum Person{
    RUN,SKIP,CRY;
}
@SuppressWarnings({"all"})
class A{
    public static void main(String[] args) {
        List objects = new ArrayList<Object>();
        objects.add(1);
    }
}